<template>
  <div>
    <div class="warn-top">
      <h4 style="text-align: left; color: #126bff">班次管理</h4>
      <!--         :rules="rules" -->
      <el-form
        ref="elForm"
        :model="formData"
        size="medium"
        label-width="80px"
        style="display: flex"
      >
        <el-form-item label="班次名称:" prop="name" style="width: 350px">
          <el-input
            v-model="formData.name"
            placeholder="请输入班次名称"
            clearable
            :style="{ width: '60%' }"
          >
          </el-input>
        </el-form-item>
        <el-form-item size="small " style="position: relative; right: 20px">
          <el-button
            @click="resetForm()"
            style="background-color: #e6effa; color: #126bff"
            >重置</el-button
          >
          <el-button
            type="primary"
            @click="submitForm(formData)"
            style="color: #ffffff; background-color: #126bff"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格 -->
    <div class="warn-content" style="width: 100%">
      <div>
        <el-button icon="el-icon-plus" @click="addTeam">添加班次</el-button>
      </div>
      <el-table
        ref="multipleTable"
        :data="
          tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
        "
        style="width: 100%; cursor: pointer"
      >
        <el-table-column prop="id" label="序号" width="100"> </el-table-column>
        <el-table-column prop="name" label="班次名称"> </el-table-column>
        <el-table-column prop="attendanceTime" label="考勤时间" width="500">
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <div>
              <el-button @click="editClick(scope.row)" type="text" size="small"
                >编辑</el-button
              >
              <el-button
                style="color: #ff4444"
                @click="deletePeople(scope.row)"
                type="text"
                size="small"
                >删除</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页器 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[1, 2, 4, 8]"
        :page-size="pageSize"
        layout="total, prev, pager, next, sizes"
        :total="tableData.length"
        style="float: right; margin-top: 20px"
      >
      </el-pagination>
    </div>
    <!-- <router-view></router-view> -->
    <div>
      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :visible.sync="dialogAddVisible"
      >
        <!-- <el-row> -->
        <el-form
          ref="elForm"
          :model="formData"
          size="medium"
          label-width="100px"
          class="addFlight"
        >
          <h3 style="text-align: left">添加班次</h3>
          <el-form-item label="班次名称" prop="FlightName">
            <el-input
              v-model="formData.FlightName"
              placeholder="请输入班次名称"
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <el-form-item label="创建人姓名" prop="founderName">
            <el-input
              v-model="formData.founderName"
              placeholder="请输入创建人姓名"
              clearable
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <h3 style="text-align: left">打卡时间</h3>
          <div>
            <div
              class="time"
              v-for="(item, index) in formData.punchTime"
              :key="index"
              @mouseenter="show(index)"
              @mouseleave="hide(index)"
            >
              <el-form-item :label="item.label1" prop="startTime">
                <el-time-picker
                  v-model="formData.punchTime[index].startTime"
                  format="HH:mm:ss"
                  value-format="HH:mm:ss"
                  :picker-options="{ selectableRange: '00:00:00-23:59:59' }"
                  :style="{ width: '100%' }"
                  placeholder="开始时间"
                  clearable
                ></el-time-picker>
              </el-form-item>
              <el-form-item :label="item.label2" prop="startTime">
                <el-time-picker
                  v-model="formData.punchTime[index].endTime"
                  format="HH:mm:ss"
                  value-format="HH:mm:ss"
                  :picker-options="{ selectableRange: '00:00:00-23:59:59' }"
                  :style="{ width: '100%' }"
                  placeholder="开始时间"
                  clearable
                ></el-time-picker>
                <i
                  v-if="deletes"
                  class="el-icon-delete"
                  style="
                    color: #ff4444;
                    width: 10px;
                    height: 10px;
                    position: absolute;
                    right: 0;
                    top: 50%;
                    transform: translate(0, -70%);
                  "
                ></i>
              </el-form-item>
            </div>
          </div>
          <button @click="addTime">添加时间段</button>
        </el-form>
        <!-- </el-row> -->
        <div slot="footer">
          <button @click="dialogAddVisible = false" class="cancel">取消</button>
          <button type="primary" @click="handelConfirm" class="confrim">
            确定
          </button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  name: "WARN",
  components: {},
  data() {
    return {
      currentPage4: 4,
      // 按页数查询数据
      currentPage: 1,
      pageSize: 4,
      deletes: true,
      formData: {
        FlightName: null,
        founderName: null,
        punchTime: [
          {
            label1: "开始时间",
            startTime: null,
            label2: "结束时间",
            endTime: null,
          },
        ],
      },
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      dialogAddVisible: false,
      tableData: [
        {
          id: 1,
          name: "测试班次1",
          attendanceTime: "07:00-09:00 11:00-13:00 14:00-15:00 18:00-19:00",
        },
        {
          id: 2,
          name: "测试班次2",
          attendanceTime: "07:00-09:00 11:00-13:00 14:00-15:00 18:00-19:00",
        },
        {
          id: 3,
          name: "默认班次",
          attendanceTime: "07:00-09:00 11:00-13:00 14:00-15:00 18:00-19:00",
        },
      ],
      initTableData: [], // 数据接收
    };
  },
  watch: {
    $route(to, from) {
      console.log(to, from);
    },
  },
  created() {},
  methods: {
    handelConfirm() {
      this.dialogAddVisible = false;
      console.log(this.formData);
    },
    // 查询信息
    submitForm(formData) {
      console.log(formData);
    },
    // 查询重置  // 重新调用
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
    // 添加班次
    addTeam() {
      this.dialogAddVisible = true;
      // this.$router.push("CheckAttendance/addAttendance");
      // this.$router.go("addAttendance");
    },
    // 分页器相关操作
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
    deletePeople(e) {
      console.log(e);
    },
    addTime() {
      console.log("11");
      this.formData.punchTime.push({
        label1: "开始时间",
        startTime: null,
        label2: "结束时间",
        endTime: null,
      });
    },
    show(e) {
      console.log(e);
      this.deletes = false;
    },
    hide(e) {
      console.log(e);
      this.deletes = true;
    },
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.warn-top {
  // border: 1px red solid;
  padding: 10px;
  background-color: white;
  border-radius: 10px;
  width: 100%;
  height: 120px;
  box-sizing: border-box;
}
.warn-top {
  width: calc(100%);
}
/deep/.el-form {
  display: flex;
  height: 80px;
  align-items: center;
}
.el-table {
  width: calc(100%);
}
/deep/.el-form-item__label {
  // border: 1px red solid;
  width: 90px !important;
  text-align: right;
}
/deep/.el-input--medium {
  position: relative !important;
  right: 30px !important;
}
/deep/.el-range-editor--medium .el-range-separator {
  line-height: 21px;
  font-size: 14px;
}
/deep/ .el-range__icon {
  line-height: 21px;
}
/deep/.el-input--medium .el-input__icon {
  line-height: 44px !important;
}
// /deep/.el-form-item__content {
//   border: 1px red solid;
// }
.warn-content {
  margin-top: 20px;
  // border: 1px red solid;
  height: auto;
  background-color: white;
  border-radius: 10px;
  padding: 10px;
  box-sizing: border-box;
}
.warn-content > div:nth-of-type(1) {
  display: flex;
  padding: 10px 0 10px 0;
  // border: 1px red solid;
}
.warn-content > div:nth-of-type(1) > button:nth-of-type(1) {
  font-size: small;
  width: 108px;
  height: 36px;
  background: #126bff;
  border-radius: 8px 8px 8px 8px;
  color: #ffffff;
}
.warn-content > div:nth-of-type(1) > button:nth-of-type(2) {
  font-size: small;
  color: #ffffff;
  width: 108px;
  height: 36px;
  background: #ff4444;
  border-radius: 8px 8px 8px 8px;
}
.el-table .el-table__cell {
  padding: 12px 0;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
  text-align: center;
}
.upIpfo {
  display: flex;
  width: 100%;
  // border: 1px red solid;
  justify-content: space-between;
}
.upIpfo p {
  color: #13213b;
  font-size: 14px;
  font-weight: 400;
  width: 50%;
  margin-top: 10px;
  // border: 1px red solid;
  display: inline-block;
  // background-color: skyblue;
}
/deep/.el-table__header-wrapper {
  // border: 1px red solid !important;
  border-radius: 10px 10px 0 0;
}
/deep/.el-table {
  border: 1px #d7dbe3 solid;
  border-radius: 10px;
}
/deep/.el-input--medium .el-input__icon {
  line-height: 30px;
}
/deep/.has-gutter tr th {
  color: black;
  text-align: center;
  border: 1px d7dbe3 solid;
  background-color: #ecf5ff;
}

/deep/.is-leaf {
  border: 1px #d7dbe3 solid !important;
  border-top: none !important;
  border-left: none !important;
}
/deep/.el-table__cell {
  text-align: center !important;
}
/deep/.el-dialog {
  border-radius: 15px !important;
  width: 660px;
}
/deep/.el-dialog__header {
  text-align: left;
  font-weight: 600;
}

/deep/.el-input__inner {
  border: 1px solid #c4c4cf !important;
  background-color: white !important;
}
.el-dialog__header {
  padding: 0 !important;
}
.addFlight {
  // border: 1px red solid;
  height: auto;
  display: block;
}
.addFlight h3 {
  width: 64px;
  height: 21px;
  font-size: 16px;
  font-family: Microsoft YaHei-Bold, Microsoft YaHei;
  font-weight: bold;
  color: #13213b;
}
.addFlight > .el-form-item {
  position: relative;
  // border: 1px red solid;
}
// el-input el-input--medium el-input--suffix
// el-form-item__content
.addFlight > .el-form-item .el-form-item__content {
  line-height: 50px !important;
}
.addFlight > .el-form-item > .el-form-item__content .el-input {
  width: 470px !important;
  // border: 1px red solid;
  position: relative;
  left: 0px;
}
.addFlight > button {
  border: 1px #126bff solid;
  color: #126bff;
  width: 198px;
  height: 32px;
  background: #ffffff;
  border-radius: 6px 6px 6px 6px;
  opacity: 1;
  position: relative;
  top: 50px;
}
.time {
  // border: 1px red solid;
  display: flex;
}
.time > .el-form-item {
  // border: 1px red solid;
  width: 50%;
}
.time > .el-form-item > .el-form-item__content {
  position: relative;
}
.time > .el-form-item > .el-form-item__content .el-input {
  width: 190px !important;
  position: absolute !important;
  left: 90px !important;
  // border: 1px red solid;
}
/deep/.time .el-input__prefix {
  top: -4px !important;
}
/deep/.el-input__suffix {
  top: -4px !important;
}
</style>

